package com.design.mall.impl;

import com.design.mall.CashRegister;

/**
 * 返利策略
 *
 * @author by liuxin
 * @version 0.1
 */
public class CashRebate extends CashRegister {

    /**
     * 返利条件
     */
    private double moneyCondition = 0.0;
    /**
     * 返利值
     */
    private double moneyReturn = 0.0d;

    public CashRebate(double moneyCondition, double moneyReturn) {
        this.moneyCondition = moneyCondition;
        this.moneyReturn = moneyReturn;
    }

    @Override
    public double acceptCash(double money) {
        double result = money;

        if (money >= moneyCondition) {
            result = money - Math.floor(money / moneyCondition) * moneyReturn;
        }

        return result;
    }
}
